// serial_class.cpp : Defines the entry point for the console application.
//

#define PCRE_STATIC
#include <iostream>
#include "ccom.h"
#include <tchar.h>


int _tmain(int argc, _TCHAR* argv[])
{
    unsigned char c;
    char *bf = new char [100];
	char* b = bf;

    pcre * regex;
    int erroffset;
    int rc;
    const char *error;
     int ovector[30];

    ccom * com = new ccom("COM5");
	com->Configure(CBR_115200, NOPARITY, TWOSTOPBITS);
	if(com->Open() != ccom::Ok){
		std::cout << "ERROR!";
		std::cin.get();
	}
	
	for(;;){
	
		while(com->getNextChar(&c) != ccom::Error){
			std::cout << c;
			*b = c;
            if(*b == 0xA){
                *(b+1)= '\0';
                b = bf;
            }
            else
            {
                b++;
            }
			

		}
		Sleep(1);
	}	

	std::cout << std::endl;
	std::cin.get();
	return 0;
}

